---
id: "deriving-decorator"
keywords: ["deriving", "decorator"]
name: "@deriving"
summary: "This is the `@deriving` decorator."
category: "decorators"
---

When the `@deriving` decorator is applied to a **record** type,
it expands the type into a factory function plus a set of
getter/setter functions for its fields.

> Note that this is an outdated decorator and you may no longer need to use it.
> See [Convert Record Type to Abstract Record](../docs/manual/generate-converters-accessors.mdx#convert-record-type-to-abstract-record) for more details.

### Example

<CodeTab labels={["ReScript", "JS Output"]}>

```res
@deriving(abstract)
type person = {
  name: string,
  age: int,
  job: string,
}

let joe = person(~name="Joe", ~age=20, ~job="teacher")

let joeName = nameGet(joe)
let joeAge = ageGet(joe)
let joeJob = jobGet(joe)
```

```js
var joe = {
  name: "Joe",
  age: 20,
  job: "teacher",
};

var joeName = joe.name;
var joeAge = joe.age;
var joeJob = joe.job;
```

</CodeTab>

### References

- [Convert Record Type to Abstract Record](../docs/manual/generate-converters-accessors.mdx#convert-record-type-to-abstract-record)
